/**
 */
package com.avaloq.tools.ddk.checkcfg.checkcfg.impl;

import com.avaloq.tools.ddk.check.check.Check;

import com.avaloq.tools.ddk.checkcfg.checkcfg.CheckcfgPackage;
import com.avaloq.tools.ddk.checkcfg.checkcfg.ConfiguredCheck;
import com.avaloq.tools.ddk.checkcfg.checkcfg.SeverityKind;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Configured Check</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link com.avaloq.tools.ddk.checkcfg.checkcfg.impl.ConfiguredCheckImpl#getSeverity <em>Severity</em>}</li>
 *   <li>{@link com.avaloq.tools.ddk.checkcfg.checkcfg.impl.ConfiguredCheckImpl#getCheck <em>Check</em>}</li>
 * </ul>
 *
 * @generated
 */
public class ConfiguredCheckImpl extends ConfigurableSectionImpl implements ConfiguredCheck
{
  /**
   * The default value of the '{@link #getSeverity() <em>Severity</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSeverity()
   * @generated
   * @ordered
   */
  protected static final SeverityKind SEVERITY_EDEFAULT = SeverityKind.DEFAULT;

  /**
   * The cached value of the '{@link #getSeverity() <em>Severity</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSeverity()
   * @generated
   * @ordered
   */
  protected SeverityKind severity = SEVERITY_EDEFAULT;

  /**
   * The cached value of the '{@link #getCheck() <em>Check</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getCheck()
   * @generated
   * @ordered
   */
  protected Check check;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ConfiguredCheckImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return CheckcfgPackage.Literals.CONFIGURED_CHECK;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public SeverityKind getSeverity()
  {
    return severity;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void setSeverity(SeverityKind newSeverity)
  {
    SeverityKind oldSeverity = severity;
    severity = newSeverity == null ? SEVERITY_EDEFAULT : newSeverity;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CheckcfgPackage.CONFIGURED_CHECK__SEVERITY, oldSeverity, severity));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Check getCheck()
  {
    if (check != null && check.eIsProxy())
    {
      InternalEObject oldCheck = (InternalEObject)check;
      check = (Check)eResolveProxy(oldCheck);
      if (check != oldCheck)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, CheckcfgPackage.CONFIGURED_CHECK__CHECK, oldCheck, check));
      }
    }
    return check;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Check basicGetCheck()
  {
    return check;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void setCheck(Check newCheck)
  {
    Check oldCheck = check;
    check = newCheck;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CheckcfgPackage.CONFIGURED_CHECK__CHECK, oldCheck, check));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case CheckcfgPackage.CONFIGURED_CHECK__SEVERITY:
        return getSeverity();
      case CheckcfgPackage.CONFIGURED_CHECK__CHECK:
        if (resolve) return getCheck();
        return basicGetCheck();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case CheckcfgPackage.CONFIGURED_CHECK__SEVERITY:
        setSeverity((SeverityKind)newValue);
        return;
      case CheckcfgPackage.CONFIGURED_CHECK__CHECK:
        setCheck((Check)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case CheckcfgPackage.CONFIGURED_CHECK__SEVERITY:
        setSeverity(SEVERITY_EDEFAULT);
        return;
      case CheckcfgPackage.CONFIGURED_CHECK__CHECK:
        setCheck((Check)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case CheckcfgPackage.CONFIGURED_CHECK__SEVERITY:
        return severity != SEVERITY_EDEFAULT;
      case CheckcfgPackage.CONFIGURED_CHECK__CHECK:
        return check != null;
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuilder result = new StringBuilder(super.toString());
    result.append(" (severity: ");
    result.append(severity);
    result.append(')');
    return result.toString();
  }

} //ConfiguredCheckImpl
